package com.cisetech.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cisetech.service.RegionService;
import com.cisetech.vo.Page;
import com.cisetech.vo.bobocai.LRegion;
import com.cisetech.mapper.bobocai.RegionMapper;

@Service
public class RegionServiceImpl implements RegionService {
	@Autowired
	RegionMapper regionMapper;
	@Override
	public int addregion(LRegion region) {
		
		return regionMapper.addregion(region);
	}
	@Override
	public Page<LRegion> getList(LRegion region) {
		Page<LRegion> page = new Page<LRegion>();
		if(region!=null && region.getPageNo()>0){
			region.setCalculationPge((region.getPageNo()-1)*region.getPageSize());
		}
		List<LRegion> list = regionMapper.getList(region);
		Integer i = regionMapper.findListCount(region);
		page.Pagehtml(region.getPageNo(), region.getPageSize(), i, list);
		return page;
	}
	@Override
	public int deleteLRegion(String id) {
		try {
			regionMapper.deleteLRegion(id);
			return 0;
		} catch (Exception e) {
			return 1;
		}
	}

}
